<?php
	
class Connection{

	var $host = '127.0.0.1';
	var $user = 'root';
	var $pass = '';
	var $db = 'cookies_land';
	var $con;	

	public function __construct(){
		//$this->host = $host;
		//$this->user = $user;
		//$this->pass = $pass;
		//$this->db = $db;
		$con=false;
	}
	
	public function connect(){
		
		if(!$this->con){
			$connect = mysql_connect($this->host, $this->user, $this->pass);
			
			if($connect) {
				//echo "berhasil koneksi host </br>";
				$seldb = mysql_select_db($this->db);
				
				if($seldb){
					$this->con = true;
					//echo "berhasil koneksi db </br>";
					return true;
				}else{
					return false;
				}
				
			}else{
				return false;
			}	
			
		}else{
			return true;
		}
	}
	
	public function disconnect(){
		$close = mysql_close();
		
		if($this->con){
			if($close){
				$this->con=false;
                //echo "berhasil disconnect </br>";
				return true;
			}else{
				return false;
			}
		}
	}
	
	
}